package com.concurrency.example.communication;

import java.util.concurrent.TimeUnit;

/**
 *  如果一个线程A执行了thread.join()语句，其含义是：当前线程A等待thread线程终止之后才从thread.join()返回。
 *  join的使用wait()实现的
 */
public class JoinTest {
    public static void main(String[] args) throws InterruptedException{
        Thread thread = new Thread(() ->{
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.start();
        thread.join();
        System.out.println("主线程执行完毕");
    }
}
